package com.example.javabase.multithread.readwritelock;

/**
 * @author He Changjie on 2021/7/11
 */
public class ReadTask implements Runnable {
    private RWDictionary dictionary;

    public ReadTask(RWDictionary dictionary) {
        this.dictionary = dictionary;
    }

    @Override
    public void run() {
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String[] keys = dictionary.allKeys();
            for (String key : keys) {
                Object o = dictionary.get(key);
                System.out.println(key+" : "+o);
            }
        }
    }
}
